<?php 
namespace Qwadmin\Controller;

class JshenController extends ComController
{

	//行政丶财务汇总审批
	public function jtong()
	{
		$llist = $_POST;
		foreach ($llist as $k => $v) {
			// dump();
			// for ($i=0; $i <= $k ; $i++) { 
			// 	# code...
			// }
			$ment[]= $v;

			
		}
		$ments = $ment[0];
		// echo $ments;
		// exit;
		$data['stype'] = '1';

		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
		$alist = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		$glist = M('auth_group')->where(['id'=>$alist[0]['group_id']])->select();
		// dump($glist);
		// exit;
		switch ($ulist[0]['m_type']) {
			
			

			case '3':  //经理
				switch ($glist[0]['post']) {
					case '行政中心':
						$data['xtype'] = $ulist[0]['m_type'];
				
						$data['xname'] = $ulist[0]['user'];
						$data['xtime'] = date('Y-m-d');
						$look['look'] = '3';
						// dump($ments);
						// exit;

				    

						if (M('yue')->where(['sid'=>['in',$ments]])->save($data) > 0) {
							if (M('look')->where(['id'=>['in',$ments]])->save($look) > 0) {
								echo '1111';
							}
						}
						break;
					
					case '财务中心':
						$data['ctype'] = $ulist[0]['m_type'];
				
						$data['cname'] = $ulist[0]['user'];
						$data['ctime'] = date('Y-m-d');
						$look['look'] = '4';
						

						if (M('yue')->where(['sid'=>['in',$ments]])->save($data) > 0) {
							if (M('look')->where(['id'=>['in',$ments]])->save($look) > 0) {
								echo '1111';
							}
						}
						break;
					
					
				}
				break;



			case '9':  //职能总经理
			// echo '111';
			// exit;
				$data['gtype'] = $ulist[0]['m_type'];
				
				$data['gname'] = $ulist[0]['user'];
				$data['gtime'] = date('Y-m-d');
				$look['look'] = '5';
				// dump($data);

				if (M('yue')->where(['sid'=>['in',$ments]])->save($data) > 0) {
					if (M('look')->where(['id'=>['in',$ments]])->save($look) > 0) {
						echo '1111';
					}
				}
				break;

			
			
			}
		


		}





		public function xlist()
		{
						// $x_list = M('look')->where(['look'=>2,'ju'=>0,'type'=>['neq',3]])->order('time desc')->order('ment DESC')->select();
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['look'=>2,'ju'=>0,'type'=>['neq',3]])->order('time desc')->order('ment DESC')->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['look'=>2,'ju'=>0,'type'=>['neq',3]])->order('time desc')->order('ment DESC')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '公司所有临时用品申请';
					        foreach ($list as  $v) {
								$coun += $v['zong']; 
							}
							$this->assign('coun',$coun);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();
				// $y_list = M('cost')->where(['look'=>2,'ju'=>0])->order('time desc')->order('id DESC')->limit(5)->select();
			
		}







		//显示公司所有审批
		public function jlist()
		{
			$gid = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		
			$glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
			;
			$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();

			
			if ($glist[0]['title'] == '超级管理员') {
					$x_list = M('look')->where(['type'=>['in',array(0,2)]])->order('time desc')->limit(5)->select();

					// $y_list = M('cost')->order('time desc')->limit(5)->select();
					$this->assign('x_list',$x_list);
					$this->assign('y_list',$y_list);
					$this->display();
					exit;
			}
			switch ($ulist[0]['m_type']) {
				case '3':   //经理
							//显示行政申请
					switch ($glist[0]['post']) {
					case '行政中心':
						$apost = $glist[0]['post'];
						$x_list = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->order('id DESC')->select();
						$xnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->count();
						$gnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>2])->count();
						$jnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->count();
						
						$this->assign('xnum',$xnum);
						$this->assign('gnum',$gnum);
						$this->assign('jnum',$jnum);
						// $y_list = M('cost')->where(['look'=>3,'ju'=>0])->order('id DESC')->limit(5)->select();
						$type = 'xing';
						$title = '集团物资申请审批';
						$this->assign('list',$x_list);
						$this->assign('type',$type);
						$this->assign('title',$title);
						// $this->assign('y_list',$y_list);
						$this->display();
						break;
					
					case '财务中心':
						//显示急性物资申请
						$apost = $glist[0]['post'];
						$x_list = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->order('id DESC')->limit(5)->select();
						$xnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>0])->count();
						$gnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>2])->count();
						$jnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->count();
						
						$this->assign('xnum',$xnum);
						$this->assign('gnum',$gnum);
						$this->assign('jnum',$jnum);
						$title = '集团急性物资申请审批';
						// $y_list = M('cost')->where(['look'=>10,'ju'=>0])->order('id DESC')->limit(5)->select();
						$this->assign('list',$x_list);
						$this->assign('title',$title);
						// $this->assign('y_list',$y_list);
						$this->display();
						break;
					
					}


				break;

				case '4':   //行政
							//显示行政物资申请
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['look'=>2,'ju'=>0,'type'=>0])->order('time desc')->order('ment DESC')->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['look'=>2,'ju'=>0,'type'=>0])->order('time desc')->order('ment DESC')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '集团所有临时用品申请';
					        foreach ($list as  $v) {
								$coun += $v['zong']; 
							}
							$xi = 'xxx';
							$xnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->count();
							$gnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->count();
							
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
							$this->assign('coun',$coun);
							$this->assign('xi',$xi);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();


				break;


				case '5':   //财务
							//显示急性物资申请
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['look'=>3,'ju'=>0,'type'=>1])->order('time desc')->order('ment DESC')->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['look'=>3,'ju'=>0,'type'=>1])->order('time desc')->order('ment DESC')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '集团急性物资申请审批';
					        $xnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>0])->count();
							$gnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->count();
							
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        foreach ($list as  $v) {
								$coun += $v['zong']; 
							}
							$xi = 'xxx';
							$this->assign('coun',$coun);
							$this->assign('xi',$xi);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();


				break;
				case '6':   //财务
							//显示急性物资申请
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['look'=>5,'ju'=>0,'type'=>1])->order('time desc')->order('ment DESC')->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['look'=>5,'ju'=>0,'type'=>1])->order('time desc')->order('ment DESC')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '集团急性物资申请审批';
					        $xnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>0])->count();
							$gnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>1])->count();
							
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        foreach ($list as  $v) {
								$coun += $v['zong']; 
							}
							$xi = 'xxx';
							$this->assign('coun',$coun);
							$this->assign('xi',$xi);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();


				break;



				case '9':   //职能经理
							//显示急性物资申请;
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['look'=>4,'ju'=>0,'type'=>1])->order('time desc')->order('ment DESC')->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['look'=>4,'ju'=>0,'type'=>1])->order('time desc')->order('ment DESC')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '公司急性物资申请审批';
					        $xnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>0])->count();
							$gnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>1])->count();
							
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        foreach ($list as  $v) {
								$coun += $v['zong']; 
							}
							// $xi = 'xxx';
							$this->assign('coun',$coun);
							$this->assign('xi',$xi);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();


				break;

			}




			
		}//END




	public function xindex()
	{
		// dump($_GET);
		$type = $_GET['type'];
		$gid = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		// dump($gid);
		// exit;
		$glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
		// dump($glist);
		// exit;
		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
		$apost = $glist[0]['post'];
			// echo $apost;
			// exit;
		// dump($type);
		// exit;
		switch ($type) {
			case '1': //固定资产购置审批

				switch ($ulist[0]['m_type']) {
					case '3':  //经理/总监
							switch ($glist[0]['post']) {
								case '行政中心':
									$apost = $glist[0]['post'];
									$db = M("look");
							        $count = $db->where(['look'=>2,'ju'=>0,'type'=>2])->order('ment DESC')->count();
							        $pagecount = 10;
							        $page = new \Think\Page($count , $pagecount);
							        // $row[] = '';
							        $page->parameter = $row; //此处的row是数组，为了传递查询条件
							        $page->setConfig('first');
							        $page->setConfig('prev','上一页');
							        $page->setConfig('next','下一页');
							        $page->setConfig('last','尾页');
							        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
							        $show = $page->show();
							        $list = $db->where(['look'=>2,'ju'=>0,'type'=>2])->order('ment DESC')->limit($page->firstRow.','.$page->listRows)->select();
							        $xnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->count();
									$gnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>2])->count();
									$jnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->count();
									
									$this->assign('xnum',$xnum);
									$this->assign('gnum',$gnum);
									$this->assign('jnum',$jnum);
							        $this->assign('page',$show);
									$title = '公司固定资产购置审批';
									$this->assign('title',$title);
									$this->assign('list',$list);
									$this->assign('type',$type);
									// $this->assign('y_list',$y_list);
									$this->display();
									break;
								
								case '财务中心':
									$db = M("look");
							        $count = $db->where(['look'=>3,'ju'=>0,'type'=>2])->order('ment DESC')->count();
							        $pagecount = 10;
							        $page = new \Think\Page($count , $pagecount);
							        // $row[] = '';
							        $page->parameter = $row; //此处的row是数组，为了传递查询条件
							        $page->setConfig('first');
							        $page->setConfig('prev','上一页');
							        $page->setConfig('next','下一页');
							        $page->setConfig('last','尾页');
							        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
							        $show = $page->show();
							        $list = $db->where(['look'=>3,'ju'=>0,'type'=>2])->order('ment DESC')->limit($page->firstRow.','.$page->listRows)->select();
							        $this->assign('page',$show);
							        $xnum = 0;
									$gnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>2])->count();
									$jnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->count();
									
									$this->assign('xnum',$xnum);
									$this->assign('gnum',$gnum);
									$this->assign('jnum',$jnum);
							        $this->assign('page',$show);
									$title = '集团固定资产购置审批';
									$this->assign('title',$title);
									$this->assign('list',$list);
									// $this->assign('y_list',$y_list);
									$this->display();
									break;
								
								
							}		
						break;
					case '4':  //行政
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['type'=>2,'look'=>2,'ju'=>0])->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['type'=>2,'look'=>2,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '集团固定资产购置审批';
					        $xnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->count();
									$gnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>2])->count();
									$jnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->count();
									
									$this->assign('xnum',$xnum);
									$this->assign('gnum',$gnum);
									$this->assign('jnum',$jnum);
							        $this->assign('page',$show);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();
						break;
					case '5':  //财务
							$db = M("look");
							$count = $db->where(['look'=>3,'ju'=>0,'type'=>2])->order('ment DESC')->count();
							$pagecount = 10;
							$page = new \Think\Page($count , $pagecount);
							// $row[] = '';
							$page->parameter = $row; //此处的row是数组，为了传递查询条件
							$page->setConfig('first');
							$page->setConfig('prev','上一页');
							$page->setConfig('next','下一页');
							$page->setConfig('last','尾页');
							$page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
							$show = $page->show();
							$list = $db->where(['look'=>3,'ju'=>0,'type'=>2])->order('ment DESC')->limit($page->firstRow.','.$page->listRows)->select();
							$this->assign('page',$show);
							$xnum = $xnum = 0;
							$gnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->count();
									
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
							$this->assign('page',$show);
					        $title = '集团固定资产购置审批';
					       	$this->assign('list',$list);
					        $this->assign('title',$title);
							$this->display();
						break;
					case '6':  //董事办
							//急性物资审批
							$db = M("look");
					        $count = $db->where(['type'=>2,'look'=>5,'ju'=>0])->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['type'=>2,'look'=>5,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '公司固定资产购置审批';
					        $xnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>0])->count();
							$gnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>1])->count();
									
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();
						break;

					
					case '9':  //总经理(职)
							
							 $where = [
			            		
			            		'look' => 4,
			            		'type'=> 2,
			            		'ju'   => 0

			        		];
							$db = M("look");
							$count = $db->where($where)->order('ment DESC')->count();
							// dump($count);
							// exit;
							$pagecount = 10;
							$page = new \Think\Page($count , $pagecount);
							// $row[] = '';
							$page->parameter = $row; //此处的row是数组，为了传递查询条件
							$page->setConfig('first');
							$page->setConfig('prev','上一页');
							$page->setConfig('next','下一页');
							$page->setConfig('last','尾页');
							$page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
							$show = $page->show();
							$list = $db->where($where)->order('ment DESC')->limit($page->firstRow.','.$page->listRows)->select();
							$this->assign('page',$show);
							$xnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>0])->count();
							$gnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>1])->count();
									
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
							$title = '公司固定资产购置审批';
							$this->assign('title',$title);
							$this->assign('list',$list);
							$this->display();
						break;
				}
				
					
				break;




			case '2': //行政物资审批
				switch ($ulist[0]['m_type']) {
					
					case '3':  //经理/总监
							switch ($glist[0]['post']) {
								case '行政中心':
									$apost = $glist[0]['post'];
									$x_list = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->order('id DESC')->limit(5)->select();
									// $y_list = M('cost')->where(['look'=>8,'ju'=>0])->order('id DESC')->limit(5)->select();
								
									$title = '公司行政物资审批';
									$xnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->count();
									$gnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>2])->count();
									$jnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->count();
									$x = 1;
									$this->assign('x',$x);
									$this->assign('xnum',$xnum);
									$this->assign('gnum',$gnum);
									$this->assign('jnum',$jnum);
									$this->assign('title',$title);
									$this->assign('list',$x_list);
									$this->assign('type',$type);
									// $this->assign('y_list',$y_list);
									$this->display();
									break;
								
								case '财务中心':
									
									$title = '公司行政物资审批';
									$this->assign('title',$title);
									// $this->assign('list',$x_list);
									// $this->assign('y_list',$y_list);
									$this->display();
									break;
								
								
							}
						break;
					case '4':  //行政
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['type'=>0,'look'=>2])->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['type'=>0,'look'=>2])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '公司行政物资审批';
					        $xnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->count();
							$gnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->count();
							$x = 1;
							$this->assign('x',$x);
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();
						break;
					case '5':  //财务
							$xnum = '0';
							$gnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->count();
							$x = 1;
							$this->assign('x',$x);
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        $title = '公司行政物资审批';
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();
						break;
					case '6':  //董事办
							$xnum = '0';
							$gnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>1])->count();
							$x = 1;
							$this->assign('x',$x);
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        // $list = $db->where(['type'=>0,'look'=>4])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '公司行政物资审批';
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();
						break;
					
					case '9':  //总经理(职)
							$xnum = '0';
							$gnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>1])->count();
							$x = 1;
							$this->assign('x',$x);
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
							$title = '公司行政物资审批';
							$this->assign('title',$title);
							$this->assign('list',$x_list);
							// $this->assign('y_list',$y_list);
							$this->display();
						break;
					


					
				}
				

				break;



			case '3':  //急性行政物资审批
				switch ($ulist[0]['m_type']) {
					
					case '3':  //经理/总监
							switch ($glist[0]['post']) {
								case '行政中心':
									$apost = $glist[0]['post'];
									$x_list = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->order('id DESC')->limit(5)->select();
									// $y_list = M('cost')->where(['look'=>8,'ju'=>0])->order('id DESC')->limit(5)->select();
									$type = 'xing';
									$title = '公司急性行政物资审批';
									$xnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->count();
									$gnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>2])->count();
									$jnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->count();
											
									$this->assign('xnum',$xnum);
									$this->assign('gnum',$gnum);
									$this->assign('jnum',$jnum);
									$this->assign('title',$title);
									$this->assign('list',$x_list);
									$this->assign('type',$type);
									// $this->assign('y_list',$y_list);
									$this->display();
									break;
								
								case '财务中心':
									$apost = $glist[0]['post'];
									$x_list = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->order('id DESC')->limit(5)->select();
									// $y_list = M('cost')->where(['look'=>10,'ju'=>0])->order('id DESC')->limit(5)->select();
									$title = '公司急性行政物资审批';
									$xnum = '0';
									$gnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>2])->count();
									$jnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->count();
											
									$this->assign('xnum',$xnum);
									$this->assign('gnum',$gnum);
									$this->assign('jnum',$jnum);
									$this->assign('title',$title);
									$this->assign('list',$x_list);
									// $this->assign('y_list',$y_list);
									$this->display();
									break;
								
								
							}
						break;
					case '4':  //行政
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['type'=>1,'look'=>2,'ju'=>0])->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['type'=>1,'look'=>2,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '公司急性行政物资审批';
					        $xnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>0])->count();
							$gnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>2,'ju'=>0,'type'=>1])->count();
											
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();
						break;
					case '5':  //财务
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['type'=>1,'look'=>3,'ju'=>0])->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['type'=>1,'look'=>3,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '公司急性行政物资审批';
					        $xnum = '0';
							$gnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>3,'ju'=>0,'type'=>1])->count();
											
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();
						break;
					case '6':  //董事办
							$db = M("look");
					        // $where = "a_id=".$uid;
					        $count = $db->where(['type'=>1,'look'=>5])->count();
					        $pagecount = 10;
					        $page = new \Think\Page($count , $pagecount);
					        // $row[] = '';
					        $page->parameter = $row; //此处的row是数组，为了传递查询条件
					        $page->setConfig('first');
					        $page->setConfig('prev','上一页');
					        $page->setConfig('next','下一页');
					        $page->setConfig('last','尾页');
					        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
					        $show = $page->show();
					        $list = $db->where(['type'=>1,'look'=>5])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
					        $title = '急性行政物资审批';
					        $xnum = '0';
							$gnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>5,'ju'=>0,'type'=>1])->count();
											
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
					        $this->assign('list',$list);
					        $this->assign('page',$show);
					        $this->assign('title',$title);
							$this->display();
						break;
					
					case '9':  //总经理(职)
							// $apost = $glist[0]['post'];
							// $mlist = M('auth_group')->where(['mtype'=>2])->select();
							// // dump($mlist);
							// // exit;
							// foreach ($mlist as $vn) {
							// // echo $v['n_id'];
							// // exit;
							// // $ment .= "`ment`="."'".$vn['title']."'"." or ";
							// // $ment .= "'".$vn['title']."'"." , ";
							// 	$ments[] =  $vn['title'];
							// 	// 

							// }
							 $where = [
			            		
			            		'look' => 4,
			            		'type'=>1,
			            		'ju'   => 0

			        		];

			    //     			dump($where);
							// exit;
							// $ments = $ment."`look`= 1"." "."or"." "."`ju`= 0";
							
							
							// $ment = "(".rtrim($ment,'or ').")"."AND"."("."`look`= 1"." "."AND"." "."`ju`= 0".")";
							
							// $ment =rtrim($ment,', ');
							// echo $ment;
							// exit;
							$x_list =  M('look')->where($where)->order('ment DESC')->limit(5)->select();
							// $x_list = "SELECT * FROM oa_look where ment in($ment) AND (`look`= 1 AND `ju`=0)";
							// dump($x_list);
							// exit;
							// $y_list = M('cost')->where(['type'=>1,'look'=>1,'ju'=>0,'ment'=>$ment])->order('id DESC')->limit(5)->select();
							$this->assign('list',$x_list);
							$xnum = '0';
							$gnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>2])->count();
							$jnum = M('look')->where(['look'=>4,'ju'=>0,'type'=>1])->count();
											
							$this->assign('xnum',$xnum);
							$this->assign('gnum',$gnum);
							$this->assign('jnum',$jnum);
							// $this->assign('y_list',$y_list);
							$title = '部门急性行政物资审批';
							$this->assign('title',$title);
							$this->display();
						break;
				


				break;
			
			// $this->display();
		}
	}

}





	public function jche()
	{
		$gid = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		// dump($gid);
		// exit;
		$glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
		// dump($glist);
		// exit;
		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
		$apost = $glist[0]['post'];
		$db = M("turn");
		// $where = "a_id=".$uid;
		$count = $db->where(['type'=>1,'look'=>8,'ment'=>$apost,'ju'=>0])->count();
		$pagecount = 10;
		$page = new \Think\Page($count , $pagecount);
					 		// $row[] = '';
		$page->parameter = $row; //此处的row是数组，为了传递查询条件
		$page->setConfig('first');
		$page->setConfig('prev','上一页');
		$page->setConfig('next','下一页');
		$page->setConfig('last','尾页');
		$page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
		$show = $page->show();
		$list = $db->where(['type'=>1,'look'=>8,'ment'=>$apost,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
		$title = '行政部门市内派车申请';

		$xing = 1;
											
		$this->assign('xnum',$xnum);
		$this->assign('gnum',$gnum);
		$this->assign('jnum',$jnum);
		$this->assign('list',$list);
		$this->assign('xing',$xing);
		$this->assign('page',$show);
		$this->assign('title',$title);
		$this->display();
	}




	public function jchew()
	{
		$gid = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		// dump($gid);
		// exit;
		$glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
		// dump($glist);
		// exit;
		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
		$apost = $glist[0]['post'];
		$db = M("turn");
		// $where = "a_id=".$uid;
		$count = $db->where(['type'=>2,'look'=>8,'ment'=>$apost,'ju'=>0])->count();
		$pagecount = 10;
		$page = new \Think\Page($count , $pagecount);
					 		// $row[] = '';
		$page->parameter = $row; //此处的row是数组，为了传递查询条件
		$page->setConfig('first');
		$page->setConfig('prev','上一页');
		$page->setConfig('next','下一页');
		$page->setConfig('last','尾页');
		$page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
		$show = $page->show();
		$list = $db->where(['type'=>2,'look'=>8,'ment'=>$apost,'ju'=>0])->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
		$title = '行政部门市外派车申请';

		$xing = 1;
												
		$this->assign('xnum',$xnum);
		$this->assign('gnum',$gnum);
		$this->assign('jnum',$jnum);
		$this->assign('list',$list);
		$this->assign('xing',$xing);
		$this->assign('page',$show);
		$this->assign('title',$title);
		$this->display();
	}



	//派车申请一键通过
	public function ctong()
	{
		$llist = $_POST;
		foreach ($llist as $k => $v) {
			// dump();
			// for ($i=0; $i <= $k ; $i++) { 
			// 	# code...
			// }
			$ment[]= $v;

			
		}
		$ments = $ment[0];
		$data['stype'] = '1';
	
		$data['type'] = '1';
		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
		$alist = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		$glist = M('auth_group')->where(['id'=>$alist[0]['group_id']])->select();
		$ss = M('yue')->where(['sid'=>['in',$ments]])->select();
		$data['jtype'] = $ulist[0]['m_type'];

		$data['jname'] = $ulist[0]['user'];
		$data['jtime'] = date('Y-m-d');
		$look['look'] = '2';
					
		if (M('che')->where(['sid'=>['in',$ments]])->save($data) > 0) {
			if (M('turn')->where(['id'=>['in',$ments]])->save($look) > 0) {
				echo '1111';
			}
		}
	}

//单个派车申请拒绝
	public function cju()
	{
		$sid = $_POST['id'];
		
		
		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
		$alist = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		$glist = M('auth_group')->where(['id'=>$alist[0]['group_id']])->select();
		
		$data['sid'] = $sid;
		$data['stype'] = '2';
		if ($_POST['lei'] == 1) {
			$data['type'] = '1';
		}else{
			$data['type'] = '2';
		}
		$data['jtype'] = $ulist[0]['m_type'];
		$data['jname'] = $ulist[0]['user'];
		$data['jtime'] = date('Y-m-d');
		$look['ju'] = '2';
		if (M('che')->where(['sid'=>$sid])->save($data) > 0) {
			if (M('turn')->where(['id'=>$sid])->save($look) > 0) {
				echo '1111';
			}
		}
	}




//单个派车申请通过
	public function csh()
	{
		
		$sid = $_POST['id'];
		
		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
		$gid = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		$glist = M('auth_group')->where(['id'=>$gid[0]['group_id']])->select();
		$apost = $glist[0]['post'];
		// dump($apost);
		// exit;
		$data['sid'] = $sid;
		$data['stype'] = '1';
		if ($_POST['lei'] == 1) {
			$data['type'] = '1';
		}else{
			$data['type'] = '2';
		}
				$data['jtype'] = $ulist[0]['m_type'];
				$data['jname'] = $ulist[0]['user'];
				$data['jtime'] = date('Y-m-d');
				
				$look['look'] = '2';
				if (M('che')->where(['sid'=>$sid])->save($data) > 0) {
					if (M('turn')->where(['id'=>$sid])->save($look) > 0) {
						echo '1111';
					}
				}
		}




	//派车申请一键通过
	public function cwtong()
	{
		$llist = $_POST;
		foreach ($llist as $k => $v) {
			// dump();
			// for ($i=0; $i <= $k ; $i++) { 
			// 	# code...
			// }
			$ment[]= $v;

			
		}
		$ments = $ment[0];
		$data['stype'] = '1';
	
		$data['type'] = '2';
		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
		$alist = M('auth_group_access')->where(['uid'=>$_SESSION['uid']])->select();
		$glist = M('auth_group')->where(['id'=>$alist[0]['group_id']])->select();
		$ss = M('yue')->where(['sid'=>['in',$ments]])->select();
		$data['jtype'] = $ulist[0]['m_type'];

		$data['jname'] = $ulist[0]['user'];
		$data['jtime'] = date('Y-m-d');
		$look['look'] = '2';
					
		if (M('che')->where(['sid'=>['in',$ments]])->save($data) > 0) {
			if (M('turn')->where(['id'=>['in',$ments]])->save($look) > 0) {
				echo '1111';
			}
		}
	}





}